#!/bin/bash

CD=/usr/bin/cd
REAL_CVS_META_ASSERT=/usr/mitra-dev/bin/SunOS5/cvs-meta-assert

CHECK="YES"

BASENAME=${0##*/}

function usage
{
    echo "Usage:"
    echo "    ${BASENAME} [--nocheck|--help] <meta-module> [<module> <version>]"
    echo 
    echo "  If <module> and <version> are omitted, then the last frozen "
    echo "  version of the module in the current directory is used."
    echo
}

case "$1" in
    *-nocheck)
        CHECK="NO"
        shift
        ;;
    *-h*|-\?)    
        usage
        exit 0
        ;;
esac

# If just the meta module, pass it on
if [ $# -eq 1 ]
then
    ${REAL_CVS_META_ASSERT} $1
    exit
fi


if [ $# -ne 3 ]
then
    usage
    exit 1
fi

META_MODULE=$1
MODULE=$2
VERSION=$3


if [ ${CHECK} == "YES" ]
then
    path=`cvs-module-path ${MODULE} ${VERSION}`

    if [ -z ${path} ]
    then
        echo ${MODULE} ${VERSION} does not exist >&2
        exit 1
    fi

    if [ ! -d ${path} ]
    then
        echo ${MODULE} ${VERSION} does not exist >&2
        exit 1
    fi
fi
${REAL_CVS_META_ASSERT} ${META_MODULE} ${MODULE} ${VERSION}

